* F Extensional Analysis
**# Table F.1: Allocative Distortion to Subsidy Distributio
clear

use "/Users/zerenli1992/Dropbox/revolving_door_jmp/replication_files/firm_yr_panel.dta", clear

g asset_l = log(TotalAsset+1)
g liability_l = log(TotalLiab+1)
g subsidy_total_l = log(subsidy_total+1)
g subsidy_local_l = log(subsidy_size+1)
g subsidy_favor_l = log(subsidy_favor+1)
lab var relative_tfp "Relative TFP"
lab var asset_l "Size"
lab var liability_l "Liability"
lab var subsidy_total_l "Total Subsidy"
lab var subsidy_local_l "Local Subsidy"
lab var subsidy_favor_l "Favorable Subsidy"

** specify firm controls
global firm_controls  asset_l liability_l

** regression setting
global reg_setting  lab dec(3)  nocons noas // 


reghdfe subsidy_total_l relative_tfp asset_l liability_l , absorb(sector_id  year )  vce(cluster stkcd) 
outreg2 using "$reg_rd/tfp.tex", replace $reg_setting addtext("Sector FE", "Y", "Year FE", "Y") 

reghdfe subsidy_local_l relative_tfp asset_l liability_l , absorb(sector_id  year )  vce(cluster stkcd) 
outreg2 using "$reg_rd/tfp.tex", append $reg_setting addtext("Sector FE", "Y", "Year FE", "Y") 


reghdfe subsidy_favor_l relative_tfp asset_l liability_l , absorb(sector_id  year )  vce(cluster stkcd) 
outreg2 using "$reg_rd/tfp.tex", append $reg_setting addtext("Sector FE", "Y", "Year FE", "Y") 



**# Table F.2 Public Spending Analysis

* Public wealfare analysis
global reg_rd  "~/Dropbox/revolving_door_jmp/result"

* regression output setting
global reg_setting  lab dec(3)  nocons noas // 

** Province 
use "~/Dropbox/revolving_door_jmp/replication_files/prov_df.dta", clear
lab var subsidy_total_l "All Subsidy"
lab var subsidy_fav_l "Favorable Subsidy"
lab var popul_l "Population"
lab var gdp_pc_l "GDP Per Capita"


reghdfe  spend_other_l subsidy_fav_l subsidy_total_l gdp_pc_l popul_l, absorb(prov year) cluster(prov)
outreg2 using "$reg_rd/public_welfare.tex", replace $reg_setting addtext("Year FE", "Y" ,"Province FE", "Y" ) cttop("Province") 


use "~/Dropbox/revolving_door_jmp/replication_files/city_df.dta", clear
lab var subsidy_total_l "All Subsidy"
lab var subsidy_fav_l "Favorable Subsidy"
lab var popul_l "Population"
lab var gdp_pc_l "GDP Per Capita"


reghdfe  spend_other_l subsidy_fav_l subsidy_total_l gdp_pc_l popul_l, absorb(pref year) cluster(pref)
outreg2 using "$reg_rd/public_welfare.tex", append  $reg_setting  addtext("Year FE", "Y","Prefecture FE", "Y" ) cttop("Prefecture") 


use "~/Dropbox/revolving_door_jmp/replication_files/county_df.dta", clear
lab var subsidy_total_l "All Subsidy"
lab var subsidy_fav_l "Favorable Subsidy"
lab var popul_l "Population"
lab var gdp_pc_l "GDP Per Capita"



reghdfe  spend_other_l subsidy_fav_l subsidy_total_l gdp_pc_l popul_l, absorb(county year) cluster(county)
outreg2 using "$reg_rd/public_welfare.tex", append $reg_setting  addtext("Year FE", "Y", "County FE", "Y" ) cttop("County") 



